<template>
	<view class="editor">
		<view v-html="content">
			
		</view>
		<!-- <rich-text :nodes="content"></rich-text> -->
		<!-- <roc-text :content="content"></roc-text> -->
		<!-- <u-parse :content="content | contentString"></u-parse> -->
	</view>
</template>

<script>
	export default {
		data() {
			return {
				content:'',
			}
		},
		filters:{
			contentString(text) {
				text = text.replace("<!DOCTYPE html>\n<html>\n<head>\n</head>\n<body>\n", '');
				text = text.replace("</body>\n</html>", '');
				// str.replace(/'\'/g,"")
				return text.replace(/\<img/gi, '<img class="rich-img" ')
			}
		},
		methods: {
			getContent(e){
				uni.setNavigationBarTitle({
					title:e == 'service' ? '用户协议' : e == 'privacy' ? '隐私政策' : e == 'logout' ? '注销账号' : ''
				})
				this.request.httpTokenRequest({
					url: "/index/policy",
					method: "get"
				}, {
					type:e
				}).then( data =>{
					if (data.code == 0) {
						this.content = data.data.content
						// console.log(data);
					} else {
						
					}
				})
			}
		},
		
		onLoad(option) {
			this.getContent(option.type)
		}
	}
</script>

<style lang="scss" scoped>
	.editor {
		padding: 30rpx;
	}
</style>
